package com.itheima.blog.web.controller;


import com.itheima.api.client.vo.BlogContributionVO;
import com.itheima.api.client.vo.ProvinceBLogNum;
import com.itheima.api.client.vo.TBlogByCategoryID;
import com.itheima.api.client.vo.TBlogByTagID;
import com.itheima.blog.web.service.ITBlogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.itheima.blog.web.service.ITBlogService;
import com.itheima.common.domain.PageReqDto;
import com.itheima.common.domain.R;
import com.itheima.common.domain.dto.BlogPageDto;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 博客文章表 前端控制器
 * </p>
 *
 * @author hyf
 * @since 2023-07-12
 */
@RestController
@RequestMapping("/web")
@RequiredArgsConstructor
public class TBlogController {
    private final ITBlogService blogService;
    //feign接口
    private final ITBlogService itBlogService;
    @GetMapping("/blog/detail/{blogId}")
    public R getBlogDetail(@PathVariable("blogId") Long blogId){
        return blogService.getBlogDetail(blogId);
    }
    @GetMapping("/owner/blog/queryBlog")
    List queryBlogByCategoryId(@RequestParam("ids") List<Integer> ids){
        return blogService.queryBlogByCategoryId(ids);
    }
    @GetMapping("/blog/rel/{categoryId}")
    public List<String> getBlogNameList(@PathVariable("categoryId") Long categoryId){
        return blogService.getBlogNameList(categoryId);
    }
    @PostMapping("/blog/page")
    public R getBlogList(@RequestBody BlogPageDto pageReqDto){
        return blogService.getBlogList(pageReqDto);
    }

    @ApiOperation("获得总文章数")
    @GetMapping("/owner/blogs")
    public Long getBlogs(){
        return itBlogService.getBlogs();
    }
    @ApiOperation("每个标签的文章数")
    @PostMapping("/owner/tag/blogs")
    public List<TBlogByTagID> getTBlogByTagID(){
        return itBlogService.getTBlogByTagID();
    }

    @ApiOperation("每个分类下的文章数")
    @PostMapping("/owner/category/blogs")
    public List<TBlogByCategoryID> getTBlogByCategoryID(){
        return itBlogService.getTBlogByCategoryID();
    }

    @PostMapping("/owner/contribute")
    @ApiOperation("文章贡献度")
    public List<BlogContributionVO> getBlogContributions(){
        return itBlogService.getBlogContributions();
    }

    @GetMapping("/owner/province/blogs")
    @ApiOperation("每个省份发博客数量(地图)")
    public  List<ProvinceBLogNum>  getProvinceBLogNum(@RequestParam("classify")  Integer classify){
        return itBlogService.getProvinceBLogNum(classify);
    }

}
